﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using Dm.Domain.Business;
using Dm.Domain.Entities;
using Dm.Domain.CrossCutting;
using System.ComponentModel.DataAnnotations;
using Dm.Domain.Business.Exceptions;

namespace ARPAMIS.Presentation.Web.Models.ViewModels
{
    public class RegisterStudentViewModel
    {
        public RegisterStudentViewModel(){}
        public RegisterStudentViewModel(int id)
        {
            var student = new StudentBusiness().RetrieveWithDetails(id,true,true);
            if (student != null)
            {
                this.StudentId = student.EntityId;
                this.StudentNumber = student.ControlNumber;
                this.FirstName = student.FirstName;
                this.MiddleName = student.MiddleName;
                this.LastName = student.LastName;
                this.Address = student.Address.AddressLine1;
                this.ContactNumber = student.ContactNumber;
                this.Email = student.Email;
                this.DateAttended = student.StartDate;
                this.DateGraduated = student.EndDate;
            }
            else
            {
                throw new StudentNotFoundException(id);
            }
        }

        public int StudentId { get; set; }
        [DisplayName(Settings.DisplayNames.StudentNumber)]
        public string StudentNumber { get; set; }
        [Required(ErrorMessage=Settings.ValidationMessages.FirstNameRequired)]
        [DisplayName(Settings.DisplayNames.FirstName)]
        public string FirstName { get; set; }
        [DisplayName(Settings.DisplayNames.MiddleName)]
        public string MiddleName { get; set; }
        [Required(ErrorMessage = Settings.ValidationMessages.LastNameRequired)]
        [DisplayName(Settings.DisplayNames.LastName)]
        public string LastName { get; set; }
        [Required(ErrorMessage = Settings.ValidationMessages.AddressRequired)]
        [DisplayName(Settings.DisplayNames.Address)]
        public string Address { get; set; }
        [Required(ErrorMessage = Settings.ValidationMessages.ContactNumberRequired)]
        [DisplayName(Settings.DisplayNames.ContactNumber)]
        public string ContactNumber { get; set; }
        [DisplayName(Settings.DisplayNames.Email)]
        public string Email { get; set; }


        public string Message { get; set; }
        [DisplayName(Settings.DisplayNames.DateAttended)]
        public DateTime? DateAttended { get; set; }
        [DisplayName(Settings.DisplayNames.YearLevel)]
        public int YearLevel { get; set; }
        [DisplayName(Settings.DisplayNames.DateGraduated)]
        public DateTime? DateGraduated { get; set; }

        #region ViewSpecific
        public Settings.DataManipulationMode Mode { get; set; }
        #endregion



    }
}